package com.ptu.ws.service.impl;

import com.ptu.entity.ChatMessage;
import com.ptu.mapper.ChatMessageMapper;
import com.ptu.ws.service.ChatMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ChatMessageServiceImpl implements ChatMessageService {

    @Autowired
    private ChatMessageMapper chatMessageMapper;

    @Override
    @Transactional
    public void saveMessage(ChatMessage message) {
        chatMessageMapper.insert(message);
    }


    @Override
    public List<ChatMessage> getMessagesBetweenUsers(String sender, String receiver, Integer limit) {
        return chatMessageMapper.getMessagesBetweenUsers(sender, receiver, limit);
    }

    @Override
    public List<ChatMessage> getMessagesBySessionId(String sessionId) {
        return chatMessageMapper.getMessagesBySessionId(sessionId);
    }

} 